package com.hnevc.androiduiclassone5;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * Created by Administrator on 2018/6/13.
 */

public class MyDialog extends Dialog{
    interface OnCharge{
        void updateAmount(String amount);
    }
    OnCharge onCharge;

    String carNumber;
    TextView mTvMessage;
    Button mBtnCharg;
    public MyDialog(@NonNull Context context) {
        super(context);

    }
    public MyDialog(@NonNull Context context,String carNumber) {
        super(context);
        this.carNumber=carNumber;
    }
    public MyDialog(@NonNull Context context,String carNumber,OnCharge onCharge) {
        super(context);
        this.carNumber=carNumber;
        this.onCharge=onCharge;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.my_dialog);

        mTvMessage=findViewById(R.id.tv_carnumber);
        mTvMessage.setText(carNumber);

        mBtnCharg=findViewById(R.id.btn_charge);
        mBtnCharg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText mEtAmount=findViewById(R.id.et_amount);
                String amount=mEtAmount.getText().toString();
                onCharge.updateAmount(amount);
                dismiss();

            }
        });

    }
}
